package com.ecnu.sei.app.course;

import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

import com.ecnu.sei.app.resources.Classroom;
import com.ecnu.sei.app.resources.Time;
import com.ecnu.sei.app.teacher.AbstractTeacher;
import com.ecnu.sei.app.teacher.Official;

public class ExamInfo {
  private Set<AbstractTeacher> proctors = new LinkedHashSet<AbstractTeacher>();
  private Time time = null;
  private Classroom classroom = null;
  private Official patrol = null;
  private Set<AbstractTeacher> backup = new HashSet<AbstractTeacher>();

  public ExamInfo() {}

  public ExamInfo(Set<AbstractTeacher> proctors, Time time,
      Classroom classroom,
 Official patrol, Set<AbstractTeacher> backup) {
    this.proctors = proctors;
    this.time = time;
    this.classroom = classroom;
    this.patrol = patrol;
    this.backup = backup;
  }

  public Set<AbstractTeacher> getProctor() {
    return proctors;
  }

  public AbstractTeacher getChief() {
    Iterator<AbstractTeacher> iterator = proctors.iterator();
    if (iterator.hasNext()) {
      return iterator.next();
    } else {
      return null;
    }
  }
  
  public AbstractTeacher[] getVices() {
    Object[] proctorArray = proctors.toArray();
    AbstractTeacher[] vices = new AbstractTeacher[proctors.size() - 1];
    for (int i = 1; i < proctorArray.length; i++) {
      vices[i - 1] = (AbstractTeacher) proctorArray[i];
    }
    return vices;
  }


  public Time getTime() {
    return time;
  }


  public Classroom getClassroom() {
    return classroom;
  }

  public Official getPatrol() {
    return patrol;
  }

  public Set<AbstractTeacher> getBackup() {
    return backup;
  }



  public ExamInfo addProctor(Set<AbstractTeacher> proctors) {
    proctors.addAll(proctors);
    return this;
  }

  public ExamInfo addProctor(AbstractTeacher proctor) {
    proctors.add(proctor);
    return this;
  }

  public ExamInfo setTime(Time time) {
    this.time = time;
    return this;
  }

  public ExamInfo setClassroom(Classroom classroom) {
    this.classroom = classroom;
    return this;
  }

  public ExamInfo setPatrol(Official patrol) {
    this.patrol = patrol;
    return this;
  }

  public ExamInfo addBackup(AbstractTeacher teacher) {
    this.backup.add(teacher);
    return this;
  }

  public ExamInfo setBackup(Set<AbstractTeacher> backup) {
    this.backup = backup;
    return this;
  }

  @Override
  public String toString() {
    return "ExamInfo [proctors=" + proctors + ", classroom="
        + classroom + ", patrol=" + patrol + ", backup=" + backup + "]";
  }
  
  
}
